 /*
 * @description: 模版控件
 * @Author: along
 * @Date: 2020-09-07
 * @Last Modified by: along
 * @Last Modified time: 2020-09-11
 */
<template>
    <div class="contro">
        <div class="title">模块控件</div>
        <div class="control-line"/>
        <div
            v-if="data && data.length > 0"
            class="control-main"
        >
            <div
                v-for="(item,index) in data"
                :key="index"
                class="contro-list"
            >
                <div
                    class="head"
                >
                    <i class="iconfont el-icon-hand-xialaicon"/>
                    <p class="head-title">{{ item.title }}</p>
                </div>
                <div
                    v-if="item.list && item.list.length > 0"
                    class="wrap-list"
                >
                    <div
                        v-for="(option,i) in item.list"
                        :key="i"
                        @click="changeControl(option)"
                        class="wrap"
                        :style="{pointerEvents: item_type_list.includes(option.type) ? '' : 'none'}"
                    >
                        <template v-if="item_type_list.includes(option.type)">
                            <i
                                v-if="!!option.iconfont"
                                class="iconfont wrap-icon"
                                :class="option.iconfont"
                            />
                            <img
                                v-else
                                :src="option.images"
                                :style="{
                                    width: '36px',
                                    height: '36px',
                                    marginTop: '12px',
                                    marginBottom: '10px'
                                }"
                            >
                            <p class="wrap-title">{{ option.title }}</p>
                        </template>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'Contro',
    props: {
        data: {
            type: Array,
            default: () => {}
        }
    },
    data () {
        return {
            // 展示组件
            item_type_list: []
        };
    },
    mounted () {
        this.checkControl();
    },
    methods: {
        changeControl (row) {
            this.$emit('handle', row);
        },

        /**
         * @description 查看组件
         */
        checkControl () {
            // console.log(this.$route.query.default);

            this.$post('/student/custom_page_for_shop_index%5Cget_valid_item_type_list',{
                default: this.$route.query.default
            },resp=>{
                if (resp.code == 1) {
                    this.item_type_list = resp.data.item_type_list;

                    this.item_type_list.push(12);

                    // 系统组件为空
                    // if(JSON.stringify(this.item_type_list) == '[1,2]') {}
                } else if (resp.code == 0) {
                    this.$notify({
                        title: '提示',
                        message: resp.msg,
                        type: 'warning',
                        duration: 2000
                    });
                }
            });
        }
    }
};
</script>

<style lang="less" scoped>
.contro {
    width: 256px;
    display: flex;
    flex-direction: column;
    margin: 24px 70px 24px 32px;
    box-sizing: border-box;
    padding: 35px 0px;
    padding-bottom: 0;
    background: #ffffff;
    position: relative;
    height: 703px;
    .control-line {
        width: 256px;
        height: 1px;
        background: #F0F2F7;
        left: 0;
        top: 63px;
    }
    .title {
        color: #333333;
        font-size: 16px;
        font-weight: bold;
        width: 100%;
        white-space: nowrap;
        margin-bottom: 35px;
        margin-left: 24px;
    }
    .control-main {
        overflow: hidden;
        overflow-y: auto;
        &::-webkit-scrollbar {
            width: 2px;
        }
    }
    .contro-list {
        display: flex;
        flex-direction: column;
        margin-bottom: 20px;
        margin-left: 24px;
        margin-top: 10px;
        .head {
            width: 208px;
            height:38px;
            display: flex;
            align-items: center;
            .el-icon-hand-xialaicon {
                color: #333333;
                font-size: 15px;
                position: relative;
                top: -2px;
                transition: all .2s;
            }
            .head-title {
                font-size: 14px;
                font-weight: 500;
                color: #333333;
                margin-left: 5px;
            }
        }
        .wrap-list {
            display: flex;
            width: 208px;
            flex-wrap: wrap;
            .wrap {
                width: 104px;
                height: 104px;
                display: flex;
                flex-direction: column;
                align-items: center;
                cursor: pointer;
                .wrap-icon {
                   font-size: 36px;
                   color: rgba(159,165,176,1);
                   margin-top: 12px;
                   margin-bottom: 10px;
                }
                .wrap-title {
                    color: #666666;
                    font-size: 14px;
                }
            }
        }
    }
}
</style>